package top.zhangjianyong.blog.params.comment;

import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;

/**
 * 评论树查询参数
 *
 * @author zhangjianyong
 * @since 2024/12/19
 */
public record CommentTreeParam(
    @NotNull(message = "博客ID不能为空") Long blogId,
    @Min(value = 1, message = "页码不能小于1") Integer pageNum,
    @Min(value = 1, message = "每页数量不能小于1") @Max(value = 50, message = "每页数量不能超过50")
        Integer pageSize,
    @Min(value = 1, message = "子评论加载数量不能小于1") @Max(value = 20, message = "子评论加载数量不能超过20")
        Integer childrenLimit,
    String sortType, // latest, oldest, hot
    Boolean onlyTopLevel // 是否只加载顶级评论
    ) {
  public CommentTreeParam {
    if (pageNum == null) pageNum = 1;
    if (pageSize == null) pageSize = 10;
    if (childrenLimit == null) childrenLimit = 5;
    if (sortType == null) sortType = "latest";
    if (onlyTopLevel == null) onlyTopLevel = false;
  }
}
